package com.menhai.personmanagement.services;

import com.menhai.personmanagement.entity.EducationBook;
import com.menhai.personmanagement.entity.EducationLog;
import com.menhai.personmanagement.entity.User;
import com.menhai.personmanagement.mapper.EducationBookMapper;
import com.menhai.personmanagement.mapper.UserMapper;
import com.menhai.personmanagement.plus.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 证书信息 服务类
 * </p>
 *
 * @author shikun
 * @since 2021-12-02
 */
 @Service
public class IEducationBookService{

   @Autowired
   private EducationBookMapper educationBookMapper;

   @Autowired
   private UserMapper userMapper;

 /**
  * @describe 删除医生得证书
  * @param educationBook
  * @Return int
  * @Date 2021/12/6 10:01
  * @author shikun
  */
 public int deleteById(EducationBook educationBook){
  return educationBookMapper.deleteById(educationBook.getProvebookid());
 }

 /**
  * @describe 根据医生id 查询证书
  * @param educationBook
  * @Return java.util.List<com.menhai.personmanagement.entity.EducationBook>
  * @Date 2021/12/6 10:11
  * @author shikun
  */
 public List<EducationBook> EducationBookByUserIdList(EducationBook educationBook){

  return educationBookMapper.selectByuserid(educationBook.getUserid());

 };


 /**
  * @describe  根据 证书id 查询证书实体
  * @param educationBook
  * @Return java.util.List<com.menhai.personmanagement.entity.EducationBook>
  * @Date 2021/12/6 15:23
  * @author shikun
  */
 public List<EducationBook> selectByprovebookid(EducationBook educationBook){

  return educationBookMapper.selectByprovebookid(educationBook.getProvebookid());

 };


 /**
  * @describe 修改 证书实体
  * @param educationBook
  * @Return int
  * @Date 2021/12/6 15:49
  * @author shikun
  */
 public int updateByIdprovebook(EducationBook educationBook){
  userMapper.updateById(User.builder().id(educationBook.getUserid()).audit("1").build());
  educationBook.setUtime(DateUtils.getLocalTime());
  return educationBookMapper.updateById(educationBook);

 };


 /**
  * @describe 新增 证书实体
  * @param educationBook
  * @Return int
  * @Date 2021/12/6 15:49
  * @author shikun
  */
 public int educationBookinsert(EducationBook educationBook){
  userMapper.updateById(User.builder().id(educationBook.getUserid()).audit("1").build());
  educationBook.setCtime(DateUtils.getLocalTime());
  return educationBookMapper.insert(educationBook);

 };

}
